package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.ProductBean;
import com.project.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private IProductService productService;

    @RequestMapping("findByItem")
    public IPage<ProductBean> findByItem(Integer pageNO, String name, Integer startNum, Integer endNum, String info, String type) {
       return productService.findByItem(pageNO, name, startNum, endNum, info, type);
    }

    @RequestMapping("findById")
    public ProductBean findById(String productId) {
        return productService.findById(productId);
    }

    @RequestMapping("updatePrice")
    public String updatePrice(String product, Integer price) {
       productService.updatePrice(product, price);
       return "ok";
    }
    @RequestMapping("findType")
    public List<String> findType() {
        return productService.findAllType();
    }
}
